<template>
  <div>
    <div class="main">
      <div class="topBox">
        <div class="topBox-bottom">
          <div>当前位置:</div>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/mall/container' }"
              >首页</el-breadcrumb-item
            >
            <el-breadcrumb-item :to="{ path: '/mall/shopcart' }"
              >购物车</el-breadcrumb-item
            >
            <el-breadcrumb-item :to="{ path: '/mall/submitOrder' }"
              >提交订单</el-breadcrumb-item
            >
          </el-breadcrumb>
        </div>
      </div>
      <div class="bottomBox">
        <div class="selectBox">
          <div class="select-blueLeft"></div>
          <p class="selectBox-way">选择收货地址</p>
          <p class="addresses" @click="mangeAddress">管理收货地址</p>
        </div>
        <div class="selectAddress">
          <div
            v-for="(item, index) in changeListAddress"
            :key="index"
            :class="['item', selectIndex === index ? 'active' : '']"
            @click="addressChange(index)"
          >
            <img alt="" src="../../../../public/submitOrder/组 332.png" />
            <span class="label">寄送至</span>
            <i v-if="selectIndex === index" class="el-icon-success"></i>
            <div v-else class="circle"></div>
            <div class="address-main">
              <span>{{ item.province }} </span>
              <span>{{ item.city }}</span>
              <span>{{ item.district }}</span>
              <span>{{ item.detailsAddress }}</span>
              <span>{{ item.receiver }}</span>
              <span>{{ item.mobile }}</span>
            </div>
            <span v-if="item.isDefault" class="default">默认地址</span>
            <span
              v-if="selectIndex === index"
              class="edit"
              @click="handleEdit(item)"
            >
              修改本地址
            </span>
          </div>
          <span
            class="otherAddresses"
            style="
              cursor: pointer;
              color: #626262;
              font-size: 16px;
              padding-left: 175px;
            "
            @click="otherAddresses"
          >
            {{ textAddressChange }}
          </span>
        </div>
        <div class="selectBox">
          <div class="select-blueLeft"></div>
          <p class="selectBox-order">订单信息确认</p>
        </div>
        <div class="productTable">
          <el-table
            :header-cell-style="headerCellStyle"
            class="header-table"
            style="width: 100%; margin-left: -50px"
          >
            <el-table-column label="商品信息" width="335">
              <!-- <img :src="item.goodsPhoto" alt="" /> -->
            </el-table-column>
            <el-table-column label="单价" width="335"></el-table-column>
            <el-table-column label="数量" width="375"></el-table-column>
            <el-table-column label="小计" prop="city" width="295">
            </el-table-column>
          </el-table>
          <div v-for="(item, index) in getOrderList" :key="index">
            <div class="shop">
              店铺：
              <p>{{ item.mallName }}</p>
            </div>
            <el-table
              :data="item.shopcarGoods"
              :header-cell-style="headerCellStyle"
              :show-header="false"
              style="width: 100%; margin-left: -50px"
            >
              <el-table-column width="100">
                <template slot-scope="{ row }">
                  <img
                    :src="row.goodsPhoto"
                    alt=""
                    style="width: 80px; height: 80px"
                  />
                </template>
              </el-table-column>
              <el-table-column width="315">
                <template slot-scope="{ row }">
                  <p
                    style="
                      display: inline-block;
                      overflow: hidden;
                      text-overflow: ellipsis;
                      display: -webkit-box;
                      -webkit-line-clamp: 2;
                      -webkit-box-orient: vertical;
                    "
                  >
                    {{ row.goodsName }}
                  </p>
                  <p style="color: #ccc; font-size: 12px">{{ row.attrDesc }}</p>
                </template>
              </el-table-column>
              <el-table-column label="单价" prop="priceCurrent" width="320">
                <template slot-scope="{ row }">
                  <p>￥{{ (row.priceCurrent / 100).toFixed(2) }}</p>
                </template>
              </el-table-column>
              <el-table-column label="数量" width="405">
                <template slot-scope="scope">
                  <div>
                    <el-input-number
                      v-model="scope.row.goodsQuantity"
                      :max="9999"
                      :min="1"
                      label="描述文字"
                      size="mini"
                      @change="handleChange"
                      :disabled="true"
                    >
                    </el-input-number>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="小计" width="175">
                <template slot-scope="{ row }">
                  <p>
                    ￥{{
                      ((row.goodsQuantity * row.priceCurrent) / 100).toFixed(2)
                    }}
                  </p>
                </template>
              </el-table-column>
            </el-table>
            <button class="submit_btn" @click="doSubmit(item)">提交订单</button>
          </div>
          <div class="productRable_bottom">
            <div class="ordernotes">
              <span>订单备注:</span>
              <el-input
                style="width: 400px"
                v-model="text"
                type="textarea"
                placeholder="选填,请和商家协商一致,付款后商家可见"
                maxlength="200"
                show-word-limit
              >
              </el-input>
            </div>
            <div class="shoppreferential">
              <div class="shoppreferential_top2">
                <div>优惠劵:</div>
                <!-- <input type="text" /> -->
                <!-- <div>
                  <div style="margin-left: 7px" v-if="couponList.length === 0">
                    暂无优惠卷
                  </div>
                  <div style="margin-left: 7px" v-else>
                    目前可用优惠卷 {{ couponList.length }} 张
                    <el-button
                      style="margin-left: 7px; width: 100px; height: 30px"
                      @click="drawer = true"
                      type="primary"
                    >
                      选择优惠卷
                    </el-button>
                  </div>
                </div> -->
                <div v-if="couponPrice !== null" @click="selectCupon">
                  -{{ this.couponPrice / 100 }}
                </div>
                <div v-else @click="selectCupon">
                  {{ couponList.length }}张可用
                  <i class="el-icon-arrow-right"></i>
                </div>
              </div>
              <div
                class="activeCopon"
                v-if="this.activityDiscountAmountTotal !== 0"
              >
                <div>活动优惠：</div>
                <div>{{ this.activityDiscountAmountTotal }} 元</div>
              </div>
              <div class="shoppreferential_middle">
                <span>送货方式:</span>
                <!-- <span>普通配送 快递 免邮</span> -->
                <span>快递</span>
              </div>
              <!-- <div class="shoppreferential_bottom">
                <template>
                  <span>店铺合计(含运费)</span>
                  <span
                    >￥{{ (paidAmount / 100).toFixed(2) }}
                    {{
                      (paidAmount / 100).toFixed(2) -
                      (this.couponValue &&
                      typeof this.couponValue.methodAmount === "number"
                        ? this.couponValue.methodAmount / 100
                        : 0)
                    }}
                  </span>
                </template>
              </div> -->
            </div>
          </div>

          <div class="information">
            <div class="disbursements">
              <p>实付款</p>
              <p>￥</p>
              <b>{{
                (
                  (this.paidAmount -
                    this.couponPrice -
                    this.activityDiscountAmountTotal * 100) /
                  100
                ).toFixed(2)
              }}</b>
              <!-- <b>{{ this.AllPrice / 100 }}</b> -->
            </div>

            <div class="sendd">
              <p>寄送至 :</p>
              <p>
                {{ address.fullAddress }}
              </p>
            </div>
            <div class="consignee">
              <p>收货人 :</p>
              <p>{{ address.receiver }}(收) &nbsp; {{ address.mobile }}</p>
            </div>
          </div>
        </div>
        <div class="submitButton">
          <!--          <div class="goback">-->
          <!--            <img alt="" src="../../../../public//submitOrder/返回.png" />-->
          <!--            <p class="shopcar">返回购物车</p>-->
          <!--          </div>-->
        </div>
      </div>
    </div>
    <!-- 弹窗 -->
    <div class="dialog">
      <el-dialog
        :before-close="handleClose"
        :visible.sync="dialogVisible"
        center
        title="修改信息"
        width="40%"
      >
        <div class="dialogForm">
          <el-form ref="dialogForm" :model="dialogData" labelWidth="105px">
            <el-form-item label="地址信息:" prop="address">
              <el-cascader
                ref="add"
                v-model="dialogData.address"
                :options="addressList"
                clearable
                placeholder="请选择地址"
                style="width: 340px"
                @change="changeAdd"
              ></el-cascader>
            </el-form-item>
            <!-- 详细地址 -->
            <el-form-item
              label="详细地址:"
              prop="detailsAddress"
              style="margin-top: 20px"
            >
              <el-input
                v-model="dialogData.detailsAddress"
                placeholder="请输入详细地址信息，如道路、门牌号、小
区、楼栋号、单元等信息"
                style="width: 340px"
                type="textarea"
              ></el-input>
            </el-form-item>
            <!-- 收货人姓名 -->
            <el-form-item
              label="收货人姓名:"
              prop="receiver"
              style="margin-top: 20px"
            >
              <el-input
                v-model="dialogData.receiver"
                placeholder="请输入收货人姓名"
                style="width: 340px"
              ></el-input>
            </el-form-item>
            <!-- 手机号码 -->
            <el-form-item
              label="手机号码"
              prop="mobile"
              style="margin-top: 20px"
            >
              <el-input
                v-model="dialogData.mobile"
                class="input-with-select"
                placeholder="请输入您的手机号码"
                style="width: 340px"
              >
                <el-select
                  slot="prepend"
                  v-model="select"
                  placeholder="请选择"
                  size="small"
                  style="width: 140px"
                >
                  <el-option label="中国大陆 +86" value="1"></el-option>
                  <el-option label="中国大陆 +87" value="2"></el-option>
                  <el-option label="中国大陆 +88" value="3"></el-option>
                </el-select>
              </el-input>
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button
            class="btn"
            style="
              width: 73px;
              height: 40px;
              border-radius: 4px;
              font-weight: 500;
              font-size: 16px;
            "
            @click="dialogVisible = false"
            >取 消</el-button
          >
          <el-button
            class="btn"
            style="
              width: 73px;
              height: 40px;
              border-radius: 4px;
              background: #1289ff;
              font-weight: 500;
              font-size: 16px;
              color: #fff;
            "
            type="primary"
            @click="handleSub"
            >确 定</el-button
          >
        </span>
      </el-dialog>
    </div>
    <el-drawer
      title="选择优惠卷"
      :visible.sync="drawer"
      :direction="direction"
      :before-close="handleClose2"
      class="drawerLog"
      size="700px"
    >
      <div class="itemcBox" v-if="this.couponList.length !== 0">
        <div
          @click="chooseCouponHandle(item)"
          :class="{ itemc: true, selected: isSelected(item) }"
          v-for="item in couponList"
          :key="item.id"
        >
          <div class="box">
            <div class="content">
              <div class="page-group">
                <i class="fold-page"></i>
                <span class="page">
                  {{ getcouponWay(item.method) }}
                </span>
              </div>
              <div>¥{{ item.methodAmount / 100 }}</div>
              <div v-if="item.useConditions === -1">无使用限制</div>
              <div v-else>满{{ item.useConditions / 100 }}元使用</div>
              <div v-show="false">商品使用限制：{{ item.goodsNames }}</div>
              <div v-show="false">
                商品分类使用限制：{{ item.goodsCategoryNames }}
              </div>
              <div v-if="false">使用时间 : {{ item.usageTime }}</div>
              <i class="dot-left"> </i>
              <i class="dot-right"></i>
            </div>
            <div class="footer">
              <div class="footer-label">
                有效开始时间 : {{ formatDate(item.validStartDate) }}
              </div>
              <div>有效结束时间 : {{ formatDate(item.validEndDate) }}</div>
              <div></div>
              <i v-if="isSelected(item)" class="checkmark-icon">&#10003;</i>
            </div>
            <div class="ribbon">未使用</div>
          </div>
        </div>
      </div>
      <div v-else style="display: flex; align-items: center">
        <el-empty
          :image-size="200"
          style="color: black; text-align: center"
          description="暂无优惠劵可选"
        ></el-empty>
      </div>
      <div class="xin-footer">
        <el-button
          @click="drawer = false"
          style="
            width: 80px;
            height: 40px;
            font-size: 16px;
            position: absolute;
            right: 120px;
            top: 15px;
          "
          >取消</el-button
        >
        <el-button
          style="
            width: 80px;
            height: 40px;
            font-size: 16px;
            position: absolute;
            right: 20px;
            top: 15px;
          "
          type="primary"
          @click="CouponCalculationHandle"
          >确认</el-button
        >
      </div>
    </el-drawer>
    <el-dialog title="新增地址" :visible.sync="visible" width="40%">
      <AddressCon @close="close"></AddressCon>
    </el-dialog>
  </div>
</template>
<script>
// eslint-disable-next-line import/no-cycle
import {
  getAddress,
  getInsert,
  getOrder,
  CouponCalculation,
} from "@/api/mallApi/getOrderSure/getOrderSure";
import areaJson from "./area.json";
import { updateAddress } from "@/framework/api/user";
import AddressCon from "@/views/mall/components/address.vue";

export default {
  name: "SubmitOrder",
  components: { AddressCon },
  data() {
    return {
      activityId: null,
      activityDiscountAmount: [],
      activityDiscountAmountTotal: 0,
      couponPrice: null,
      AllPrice: null,
      selectedCoupon: null,
      drawer: false,
      direction: "rtl",
      // couponValue: null,
      couponList: [], //可用优惠卷列表
      visible: false,
      addressList: areaJson,
      comeFrom: 1,
      paidAmount: 0,
      totalPrice: 0,
      selectIndex: 0,
      textAddress: "显示全部地址",
      changeText: "使用其他地址",
      changeText2: "新增收货地址",
      showAllAddress: true,
      radio: "0",
      text: "",
      id: "",
      mailingAddress: "",
      getOrderList: [],
      getAddressList: [],
      orderDTO: {
        comeFrom: "",
        totalPrices: "",
        consigneeName: "string",
        consigneePhone: "string ",
        consigneeAddress: "string",
        detailAddress: "string",
        proviceCode: "string",
        cityCode: "string",
        countyCode: "string",
        orderDetailesDTOList: [{}],
        couponId: null,
      },
      address: {},
      isDisabled: false,
      dialogVisible: false,
      tableData: [],
      // 复选框
      checked: false,
      dialogData: {},
      // 详细收货地址列表
      detailedAddresList: [],
      select: "1",
      formData: {
        address: "",
        // 详细地址
        detailsAddress: "",
        // 收货人姓名
        receiver: "",
        // 手机号码
        mobile: "",
        // 省编码
        provinceCode: "",
        // 市编码
        cityCode: "",
        // 区编码
        districtCode: "",
        isDefault: 0,
        // 省
        province: "",
        // 市
        city: "",
        // 区
        district: "",
        pagesize: 10,
      },
    };
  },
  computed: {
    textAddressChange() {
      if (this.getAddressList.length > 0) {
        return this.changeText;
      } else {
        return this.changeText2;
      }
    },
    changeListAddress() {
      if (this.showAllAddress) {
        return this.getAddressList.slice(0, 5);
      } else {
        return this.getAddressList.slice(5, 10);
      }
    },
  },
  created() {
    this.getList();
    this.getAddress();
  },
  mounted() {},

  methods: {
    // this.orderDTO.couponId = item.id;
    chooseCouponHandle(item) {
      this.orderDTO.couponId = item.id === null ? "" : item.id;
      this.selectedCoupon = this.selectedCoupon === item ? null : item;
      if (this.selectedCoupon === null) {
        this.couponPrice = 0;
      }
      // console.log("this.selectedCoupon", this.selectedCoupon);
    },
    isSelected(couponId) {
      return this.selectedCoupon === couponId;
    },
    CouponCalculationHandle() {
      const index = this.selectIndex;
      this.orderDTO.paidAmount = this.paidAmount * 100;
      this.orderDTO.comeFrom = this.comeFrom;
      this.orderDTO.consigneeName = this.getAddressList[index].receiver;
      this.orderDTO.consigneePhone = this.getAddressList[index].mobile;
      this.orderDTO.consigneeAddress =
        this.getAddressList[index].detailsAddress;
      this.orderDTO.proviceCode = this.getAddressList[index].provinceCode;
      this.orderDTO.cityCode = this.getAddressList[index].cityCode;
      this.orderDTO.countyCode = this.getAddressList[index].districtCode;
      this.orderDTO.proviceName = this.getAddressList[index].province;
      this.orderDTO.cityName = this.getAddressList[index].city;
      this.orderDTO.countyName = this.getAddressList[index].district;
      this.orderDTO.totalPrices = this.totalPrice;
      this.orderDTO.orderDetailesDTOList = [];
      this.getOrderList.forEach((item) => {
        // console.log('123',item);
        const { mallCode } = item;
        for (let i = 0; i < item.shopcarGoods.length; i++) {
          const goods = item.shopcarGoods[i];
          const orderDetails = {};
          orderDetails.mallCode = mallCode;
          orderDetails.goodsId = goods.goodsId;
          orderDetails.goodsName = goods.goodsName;
          orderDetails.goodsThumbnail = goods.goodsPhoto;
          orderDetails.specAttr = goods.attrDesc;
          orderDetails.specAttrId = goods.attrId;
          orderDetails.price = goods.priceCurrent;
          orderDetails.amount = goods.goodsQuantity;
          orderDetails.activityDiscountAmount = goods.activityDiscountAmount;
          this.orderDTO.orderDetailesDTOList.push(orderDetails);
        }
      });
      if (this.getAddressList.length === 0) {
        this.$message("请先选择地址");
      } else {
        CouponCalculation(this.orderDTO)
          .then((res) => {
            if (res.code !== "00000") return;
            this.AllPrice = res.data.paidAmount;
            this.couponPrice = res.data.discountAmount;
            this.drawer = false;
            this.selectedCoupon = null;
            this.totalPrice = res.data.paidAmount;
            // console.log(res);
          })
          .catch((error) => {
            console.error("Error fetching address list: ", error);
          });
      }
    }, //优惠卷确认提交
    //点击优惠卷
    selectCupon() {
      if (this.getAddressList.length === 0) {
        this.$message("请先选择地址");
        this.drawer = false;
      } else {
        this.drawer = true;
      }
    },
    formatDate(originalTimeString) {
      if (!originalTimeString) {
        return ""; // or any default value you prefer
      }
      const [datePart, timePart] = originalTimeString.split(" ");
      const [year, month, day] = datePart.split("-");
      return `${year}.${month}.${day}`;
    },
    getcouponWay(type) {
      switch (type) {
        case 0:
          return "金额卷";
        case 1:
          return "折扣卷";
        default:
          return "未知";
      }
    },
    handleClose2(done) {
      // this.$confirm("确认关闭？")
      //   .then((_) => {
      done();
      // })
      // .catch((_) => {});
    },
    couponHandle(item) {
      //console.log(item);
    },
    close() {
      this.visible = false;
      this.getAddress();
    },
    addressChange(index) {
      this.selectIndex = index;
      this.isDefault = index;
      this.address = this.getAddressList[index];
    },
    doSubmit(item) {
      //console.log(item, "itenm");
      const index = this.selectIndex;
      this.orderDTO.paidAmount = this.paidAmount * 100;
      this.orderDTO.comeFrom = this.comeFrom;
      this.orderDTO.consigneeName = this.getAddressList[index].receiver;
      this.orderDTO.consigneePhone = this.getAddressList[index].mobile;
      this.orderDTO.consigneeAddress =
        this.getAddressList[index].detailsAddress;
      this.orderDTO.proviceCode = this.getAddressList[index].provinceCode;
      this.orderDTO.cityCode = this.getAddressList[index].cityCode;
      this.orderDTO.countyCode = this.getAddressList[index].districtCode;
      this.orderDTO.proviceName = this.getAddressList[index].province;
      this.orderDTO.cityName = this.getAddressList[index].city;
      this.orderDTO.countyName = this.getAddressList[index].district;
      // this.orderDTO.totalPrices = this.totalPrice;
      this.orderDTO.totalPrices =
        this.paidAmount -
        this.couponPrice -
        this.activityDiscountAmountTotal * 100;
      // ((this.paidAmount / 100).toFixed(2) -
      //   (this.couponPrice / 100).toFixed(2) -
      //   this.activityDiscountAmountTotal.toFixed(2)) *
      // 100;

      // this.couponPrice / 100; // 不选优惠劵 --- 选完优惠劵
      // console.log(this.paidAmount);
      // console.log(this.couponPrice);
      // console.log(this.activityDiscountAmountTotal);
      // console.log(
      //   this.paidAmount -
      //     this.couponPrice -
      //     this.activityDiscountAmountTotal * 100
      // );
      // console.log(this.activityDiscountAmountTotal * 100);
      // console.log(this.couponPrice);
      // console.log(this.orderDTO.totalPrices);

      this.orderDTO.buyerMessage = this.text;
      this.orderDTO.activityId = this.activityId;
      // this.orderDTO.couponId = this.couponValue.id;
      //console.log(this.orderDTO, "orderDTO");
      this.orderDTO.orderDetailesDTOList = [];
      // console.log("提交订单123", this.getOrderList);
      this.getOrderList.forEach((item) => {
        const { mallCode, mallName } = item;
        // console.log("item", item);
        for (let i = 0; i < item.shopcarGoods.length; i++) {
          const goods = item.shopcarGoods[i];
          // console.log("goods", goods);
          const orderDetails = {};
          orderDetails.mallCode = mallCode;
          orderDetails.goodsId = goods.goodsId;
          orderDetails.goodsName = goods.goodsName;
          orderDetails.goodsThumbnail = goods.goodsPhoto;
          orderDetails.specAttr = goods.attrDesc;
          orderDetails.specAttrId = goods.attrId;
          orderDetails.price = goods.priceCurrent;
          orderDetails.amount = goods.goodsQuantity;
          orderDetails.activityDiscountAmount = goods.activityDiscountAmount;
          orderDetails.mallName = mallName; // 添加 mallName 字段
          this.orderDTO.orderDetailesDTOList.push(orderDetails);
        }
      });
      //console.log("order", this.orderDTO);
      getInsert(this.orderDTO)
        .then((res) => {
          if (res.code !== "00000") return;
          //console.log(res.data);

          this.$router.push({
            path: "/mall/confirmAnOrder",
            query: {
              subtotal:
                this.paidAmount -
                this.couponPrice -
                this.activityDiscountAmountTotal * 100,
            },
          });
        })
        .catch((error) => {
          console.log(error);
        });
    },
    // 获取店铺商品数据
    getList() {
      getOrder().then((response) => {
        console.log("res123", response);
        this.getOrderList = response.data.list;
        this.paidAmount = response.data.totalAmount;
        this.comeFrom = response.data.comeFrom;
        // this.id=this.getOrderList
        this.activityDiscountAmountTotal =
          response.data.activityDiscountAmountTotal / 100;
        this.activityId = response.data.activityId;
        this.couponList = response.data.usableCoupons;
        this.activityDiscountAmount = response.data.list
          .map((item) =>
            item.shopcarGoods.map((goods) => goods.activityDiscountAmount)
          )
          .flat();
        // console.log(this.activityDiscountAmount);
        //console.log(this.getOrderList, "getOrderList");
        this.handleChange();
      });
    },
    // 获取地址数据
    getAddress() {
      const params = {
        offset: 0,
        pagesize: this.pagesize,
      };
      getAddress(params).then((response) => {
        this.getAddressList = response.data.records;
        if (this.getAddressList.length === 0) {
          this.address = this.getAddressList;
        } else {
          this.address = this.getAddressList[0];
        }
      });
    },
    handleChange() {
      let totalPrice = 0;
      this.getOrderList.forEach((item) => {
        for (let i = 0; i < item.shopcarGoods.length; i++) {
          const goods = item.shopcarGoods[i];
          const subtotal = goods.goodsQuantity * goods.priceCurrent;
          goods.subtotal = subtotal;
          totalPrice += subtotal;
        }
        this.paidAmount = totalPrice;
        this.totalPrice = totalPrice;
      });
    },
    mangeAddress() {
      this.$router.push({
        path: "/mall/profile/address",
      });
    },

    headerCellStyle({ column }) {
      if (column.label === "商品信息") {
        return { background: "#f8f8f8" };
      } else if (column.label === "单价") {
        return { background: "#f8f8f8" };
      } else if (column.label === "数量") {
        return { background: "#f8f8f8" };
      } else if (column.label === "小计") {
        return { background: "#f8f8f8" };
      }
    },
    otherAddresses() {
      this.visible = true;
    },
    handleEdit(item) {
      this.dialogVisible = true;
      this.dialogData = JSON.parse(JSON.stringify(item));
      this.dialogData.address = [
        item.provinceCode,
        item.cityCode,
        item.districtCode,
      ];
    },
    // 确认修改
    handleSub() {
      this.isDisabled = true;
      // 去除 address字段
      delete this.dialogData.address;
      this.dialogData.fullAddress =
        this.dialogData.province +
        this.dialogData.city +
        this.dialogData.district +
        this.dialogData.detailsAddress;
      if (this.dialogData) {
        updateAddress(this.dialogData)
          .then((res) => {
            if (res.code === "00000") {
              this.$message.success("修改成功");
              // 清空表单
              this.dialogData = {};
              this.dialogVisible = false;
              // 重新获取详细地址列表
              this.getAddress();
            }
          })
          .catch((err) => {
            this.$message.error(err);
          });
      }
    },
    // 关闭弹窗
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    changeAdd(value) {
      const res = this.$refs["add"].getCheckedNodes()[0].pathLabels;
      this.dialogData.province = res[0];
      this.dialogData.city = res[1];
      this.dialogData.district = res[2];
      this.dialogData.provinceCode = value[0];
      this.dialogData.cityCode = value[1];
      this.dialogData.districtCode = value[2];
      this.dialogData.detailsAddress = "";
    },
  },
};
</script>

<style lang="scss" scoped>
.main {
  margin: 0 auto;
  width: 1340px;
  height: auto;
  list-style: none;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  * {
    margin: 0 auto;
  }
  .topBox {
    display: flex;
    flex-direction: column;
    width: 1340px;

    .topBox-top {
      display: flex;
      align-items: center;
      justify-content: space-around;

      width: 1340px;
      height: 144px;

      border-bottom: solid 1px #1289ff;

      .logo {
        // margin-top: 45px;
        img {
          width: 233px;
          height: 55px;
        }
      }

      .searchBox {
        position: relative;

        display: flex;
        align-items: center;
        justify-content: center;

        width: 643px;
        height: 45px;

        border-radius: 4px;

        .commodity {
          // margin-left: 50px;
          font-size: 14px;

          position: absolute;
          top: -25px;
          right: 542px;

          display: flex;
          justify-content: space-between;

          p {
            display: inline-block;

            width: 28px;
            height: 20px;
            margin: 0 5px;

            cursor: pointer;
          }

          .on {
            color: #1289ff;
          }
        }

        input {
          line-height: 45px;

          width: 532px;
          height: 45px;
          padding-left: 17px;

          border: 1.5px solid #1289ff;
          border-radius: 4px;
          outline: none;
        }

        button {
          font-size: 16px;

          width: 111px;
          height: 45px;
          margin-left: -5px;

          cursor: pointer;

          color: #fff;
          border: none;
          border-radius: 4px;
          background: #1289ff;
        }
      }

      .shopCarBox {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 140px;
        height: 45px;

        border: 1px solid #d3d3d3;
        border-radius: 4px;
      }
    }

    .topBox-bottom {
      line-height: 56px;

      width: 1340px;
      height: 56px;
      // display: flex;
      // justify-content: space-around;
    }
  }

  .bottomBox {
    width: 1240px;
    height: auto;
    position: relative;
    .submit_btn {
      width: 146px;
      height: 40px;
      position: absolute;
      bottom: 0px;
      right: -42px;
      cursor: pointer;

      color: #fff;
      border: none;
      border-radius: 4px;
      background: #1289ff;
    }
    // background: #ccc;
    .selectBox {
      display: flex;
      justify-content: space-around;

      width: 1240px;
      height: 19px;
      margin-top: 25px;
      margin-bottom: 13px;

      .select-blueLeft {
        width: 4px;
        height: 19px;
        margin-left: -50px;

        border-radius: 2px;
        background: #1289ff;
      }

      .selectBox-way {
        font-size: 19px;
        font-weight: 500;
        line-height: 19px;

        margin-left: -340px;

        color: #2b2b2b;
      }

      .selectBox-order {
        font-size: 19px;
        font-weight: 500;
        line-height: 19px;

        margin-left: -1150px;

        color: #2b2b2b;
      }

      .addresses {
        margin-right: -45px;
        margin-left: 760px;

        cursor: pointer;

        color: #1289ff;
      }
    }

    .selectAddress {
      width: 1340px;
      height: auto;
      margin-top: 20px;
      margin-left: -50px;
      // display: flex;
      // justify-content: space-around;

      > .item {
        display: flex;
        align-items: center;

        padding: 12px 0;

        > .label {
          flex: none;
          margin: 0 24px 0 12px;
          opacity: 0;
          color: #1289ff;
        }

        > img {
          margin: 0 6px;

          opacity: 0;
        }

        > .default {
          font-size: 14px;

          margin-left: 24px;

          color: #626262;
        }

        ::v-deep .el-checkbox {
          margin-left: 24px;

          .el-checkbox__input.is-checked .el-checkbox__inner {
            border-color: #1289ff;
            background-color: #1289ff;
          }
        }

        .el-icon-success {
          font-size: 20px;

          margin: 0 12px;

          color: #1289ff;
        }

        .circle {
          width: 20px;
          height: 20px;
          margin: 0 12px;

          border: 1px solid #d6d6d6;
          border-radius: 999em;
          background: #fff;
        }

        .address-main {
          margin: 0 24px 0 12px;
          cursor: pointer;

          span {
            padding: 0 3px;
          }

          :nth-child(4) {
            padding-left: 40px;
          }
        }
      }

      > .item.active {
        margin-bottom: 12px;

        cursor: pointer;

        border: 1px solid #3f87f7;
        background: #f0f8fd;

        > .label {
          opacity: 1;
        }

        > img {
          opacity: 1;
        }

        > .default {
          font-size: 18px;
        }

        > .edit {
          font-size: 16px;

          cursor: pointer;

          color: #1289ff;
        }

        .address-main {
          font-size: 20px;
          font-weight: 700;

          color: #3c3c3c;
        }
      }

      .el-radio {
        display: flex;
        align-items: center;
        justify-content: space-around;

        border-radius: 2px;
      }

      .selectAddress-address {
        display: flex;
        align-items: center;

        width: 1340px;
        height: 54px;
        margin-left: -50px;

        border-radius: 2px;

        .on {
          font-size: 20px;
          font-weight: 500;

          margin-left: -100px;
        }

        .el-radio {
          display: flex;
          justify-content: space-between;
        }

        p {
          font-size: 16px;
          font-weight: 500;
          line-height: 28px;

          padding-right: 10px;

          text-align: left;

          color: #3c3c3c;
        }
      }
    }

    .productTable {
      width: 1340px;
      margin-left: -4px;

      .header-table {
        ::v-deep .el-table__body-wrapper {
          display: none;
        }
      }

      ::v-deep .el-table th > .cell {
        margin-left: 88px;

        color: #2b2b2b;
      }

      ::v-deep .el-table_2_column_6 {
        margin-left: 50px;
      }

      .shop {
        display: flex;
        justify-content: space-around;

        margin: 12px -38px;

        p {
          margin-left: -5px;
        }
      }

      ::v-deep .el-table__row > .el-table_2_column_6 el-table__cell {
        margin-left: 80px;
      }

      ::v-deep .el-table__row > .cell {
        font-size: 20px;
        font-weight: 700;

        color: #ff6b00;
      }

      .productRable_bottom {
       
        width: 1340px;
        height: 245px;
        margin-left: -50px;
        border-bottom: solid 1px #1289ff;
        background: #f7faff;
        position: relative;
        .ordernotes {
          width: 563px;
          height: 100%;
          border-right: 3px solid #fff;
          position: absolute;
          left: 17px;
          padding-top: 22px;
          span {
            font-size: 16px;
            display: inline-block;
            width: 90px;
            height: 28px;
            color: #000;
          }

          p {
            font-size: 12px;
            font-weight: 400;
          }
        }
        .shoppreferential {
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: space-around;
          position: absolute;
          left: 580px;
          top: 0;
          width: 760px;
          height: 100%;

          > div {
            width: 100%;
            min-height: 33%;
            border-bottom: 3px solid #fff;
          }
          > div:last-child {
            border-bottom: none;
          }
          > div:nth-child(1) {
            display: flex;
            align-items: center;
            justify-content: space-around;
            > div:nth-child(1) {
              position: absolute;
              left: 300px;
            }
            > div:nth-child(2) {
              position: absolute;
              right: 30px;
              font-size: 20px;
              font-weight: 700;
              color: #ff6b00;
              cursor: pointer;
            }
          }
          .activeCopon {
            display: flex;
            align-items: center;
            justify-content: space-around;
            > div:nth-child(1) {
              position: absolute;
              left: 300px;
            }
            > div:nth-child(2) {
              position: absolute;
              right: 30px;
              font-size: 20px;
              font-weight: 700;
              color: #ff6b00;
              cursor: pointer;
            }
          }
          .shoppreferential_middle {
            display: flex;
            align-items: center;
            justify-content: space-around;
            > span:nth-child(1) {
              position: absolute;
              left: 300px;
            }
            > span:nth-child(2) {
              position: absolute;
              right: 30px;
              font-size: 20px;
              font-weight: 700;
              color: #ff6b00;
              cursor: pointer;
            }
          }
        }
      }
    }

    .information {
      display: flex;
      flex-direction: column;

      width: 596px;
      height: 191px;
      margin-top: 20px;
      margin-right: 55px;

      border: 2px solid #1289ff;
      border-radius: 2px;
      background: #fff;

      .disbursements {
        line-height: 45px;

        display: flex;
        justify-content: space-around;

        height: 45px;
        margin-top: 24px;
        margin-right: 19px;

        :nth-child(1) {
          font-size: 20px;
        }

        :nth-child(2) {
          font-size: 14px;
          font-weight: 700;

          padding-top: 3px;
          padding-left: 55px;

          color: #ff6b00;
        }

        :nth-child(3) {
          font-size: 25px;
          font-weight: 700;

          color: #ff6b00;
        }
      }

      .sendd {
        display: flex;
        height: 27px;
        margin-top: 26px;
        margin-right: 10px;

        :nth-child(1) {
          font-size: 18px;
          font-weight: 700;
        }

        :nth-child(2) {
          font-size: 18px;
          color: #000;
        }

        p:nth-child(2) {
          margin-left: 20px;
        }
      }

      .consignee {
        display: flex;
        width: 304px;
        height: 27px;
        margin-top: 23px;
        margin-right: 0px;

        :nth-child(1) {
          font-size: 18px;
          font-weight: 700;
        }

        p:nth-child(2) {
          margin-left: 20px;
        }
      }
    }

    .submitButton {
      display: flex;
      justify-content: space-between;

      width: 596px;
      height: 40px;
      margin-right: -44px;
      margin-bottom: 40px;

      .goback {
        display: flex;
        align-items: center;
        justify-content: space-between;

        width: 84px;
        height: 24px;
        margin-left: 0;

        cursor: pointer;

        img {
          width: 15px;
          height: 15px;
        }

        .shopcar {
          font-size: 12px;

          color: #1289ff;
        }
      }
    }
  }

  .dialog-footer {
    .btn {
      width: 146px;
      height: 40px;
      border-radius: 4px;
      background: #1289ff;
      font-weight: 500;
      font-size: 16px;
      color: #fff;
    }
  }
}
::v-deep .drawerLog {
  color: red;

  .itemcBox {
    width: 600px;
    height: auto;
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap to the next line */
  }

  //   优惠卷样式
  .itemc {
    width: 250px;
    overflow: hidden;
    margin-bottom: 20px;
    padding-left: 2px;
    position: relative;
    margin-left: 30px;
    cursor: pointer;
  }
  .itemc.selected {
   
  }
  .checkmark-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    color: #db0113;
    font-size: 30px;
  }

  .box {
    background: #fff;
    border-radius: 5px;
    background-color: #fae8e6;
  }

  .itemc .dot-left,
  .itemc .dot-right {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f5f5f5;
    position: absolute;
    z-index: 999;
  }
  .itemc .dot-left {
    bottom: -8px;
    left: -6px;
  }
  .itemc .dot-right {
    bottom: -8px;
    right: -6px;
  }
  .itemc .page-group {
    position: absolute;
    top: 10px;
    left: -2px;
    width: 100%;
    max-width: 120px;
  }
  .itemc .page-group .fold-page {
    display: block;
    width: 2px;
    height: 5px;
    background: #db0113;
    //   background-color: #7cd1d4;
    transform: skewY(-40deg);
    position: absolute;
    top: -1px;
    left: 0;
    z-index: 0;
  }
  .itemc .page-group .page {
    position: absolute;
    z-index: 1;
    display: block;
    padding: 0 10px;
    height: 20px;
    background: linear-gradient(137deg, #ff5b5b 0%, #db0113 100%);
    // background-color: #7cd1d4;
    border-radius: 0 20px 20px 0;
    color: #fff;
    text-align: center;
    font-size: 12px;
    overflow: hidden;
  }
  .itemc .content {
    width: 100%;
    height: 200px;
    border-bottom: 5px dotted #f5f5f5;
    position: relative;
    z-index: 2;
    position: relative;
  }
  .itemc .content > div:nth-child(2) {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 40px;
    font-size: 40px;
  }
  .itemc .content > div:nth-child(3) {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100px;
    font-size: 16px;
  }
  .itemc .content > div:nth-child(4) {
    position: absolute;
    font-size: 12px;
    left: 15px;
    bottom: 30px;
  }
  .itemc .content > div:nth-child(5) {
    position: absolute;
    font-size: 12px;
    left: 15px;
    bottom: 10px;
  }
  .itemc .content > div:nth-child(6) {
    position: absolute;
    font-size: 12px;
    left: 15px;
    bottom: 50px;
  }
  .itemc .content .receive {
    position: absolute;
    font-size: 12px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
  }
  .itemc .footer {
    color: red;
    font-size: 12px;
    padding: 5px 15px 10px 15px;
    position: relative;
  }
  .footer-label {
    line-height: 24px;
  }
  .itemc .footer > div:nth-child(3) {
    position: absolute;
    background-color: #fff;
    top: 16px;
    right: 7px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
  }
  .itemc .ribbon {
    width: 80px;
    height: 20px;
    background: #dd0d1f;
    position: absolute;
    right: -20px;
    top: 10px;
    transform: rotateZ(45deg);
    text-align: center;
    color: #fff;
    font-size: 12px;
  }
  .xin-footer {
    width: 700px;
    height: 70px;
    bottom: 0;
    // background-color: red;
    position: fixed;
    z-index: 100;
    right: 0px;
  }
  .el-drawer .el-drawer__body {
    margin-bottom: 80px;
  }
}
</style>
